package domain;

import java.util.Collection;
import java.util.HashSet;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotBlank;

@Entity
@Access(AccessType.PROPERTY)
public class UserGroup extends DomainEntity {
	
	//Constructors

	public UserGroup() {
		super();
		vacancies = new HashSet<Vacancy>();
		users = new HashSet<User>();
	}
	
	//Attributes
	private String name;
	private String description;

	@NotBlank
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@NotBlank
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	//Relationships

	private Administrator administrator;
	private Collection<Vacancy> vacancies;
	private Collection<User> users;

	@Valid
	@NotNull
	@ManyToOne(optional = false)
	public Administrator getAdministrator() {
		return administrator;
	}

	public void setAdministrator(Administrator administrator) {
		this.administrator = administrator;
	}

	
	@OneToMany(mappedBy = "userGroup")
	public Collection<Vacancy> getVacancies() {
		return vacancies;
	}

	public void setVacancies(Collection<Vacancy> vacancies) {
		this.vacancies = vacancies;
	}

	
	@OneToMany(mappedBy = "userGroup")
	public Collection<User> getUsers() {
		return users;
	}

	public void setUsers(Collection<User> users) {
		this.users = users;
	}

}
